<template>
  <a-card :loading="loading" :body-style="{ padding: '10px 10px' }" :bordered="false">
    <div class="chart-card-header">
      <div class="meta">
        <span class="chart-card-title">{{ title }}</span>
        <a-icon slot="indicator" type="caret-right" style="font-size: 14px" />
        <slot></slot>
        <span class="chart-card-status" v-if="num > 0">
          {{ '+' + num }}
        </span>
        <span class="chart-card-status status-down" v-if="num < 0">
          {{ num }}
        </span>
      </div>
    </div>
  </a-card>
</template>

<script>
export default {
  name: 'ChartCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    num: {
      type: Number,
      default: ''
    },
    loading: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style lang="less" scoped>
div {
  margin-bottom: 0px !important;
}
.ant-card {
  border-radius: 10px;
  overflow: hidden;
  // box-shadow: 0px 0px 2px 2px rgb(0 0 0 / 1%), 0px 2px 2px 0px rgb(0 0 0 / 1%), 0px 0px 0px -4px rgb(0 0 0 / 2%);
}
.chart-card-header {
  position: relative;
  overflow: hidden;
  width: 100%;

  .meta {
    position: relative;
    overflow: hidden;
    width: 100%;
    color: rgba(0, 0, 0, 0.45);
    font-size: 14px;
    line-height: 22px;
  }
}

.chart-card-status {
  cursor: pointer;
  position: absolute;
  top: 0;
  right: 0;
  color: red;
}

.status-down {
  color: mediumseagreen;
}
</style>

